﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonsterEngine.Interfaces;
using MonsterEngine.Types;
using MonsterEngine.Managers;
using MonsterEngine.Augments;

namespace MonsterEngine.Abilities
{
    public class Sleep : IAbilities
    {
        public AbilityType AbilityType
        {
            get;
            set;
        }
        public string Name
        {
            get;
            set;
        }
        public string Description { get; set; }
        public int BasePoint
        {
            get;
            set;
        }
        public int AbilityKey
        {
            get;
            set;
        }
        public IFightable AbilityTarget
        {
            get;
            set;
        }
        public DamageManager AbilityDamageManager
        {
            get;
            set;
        }
        public DamageType DamageType
        {
            get;
            set;
        }

        public void DoAbility()
        {
            if (!AbilityTarget.BuffList.Exists(s => s.GetType().Name == typeof(HealOverTime).Name)) // Will have to change these to a manager at some point...
            {
                Random rnd = new Random();
                int seed = rnd.Next(1, 6);
                if (seed == 1)
                {
                    MissTurn aug = new MissTurn();
                    aug.WornOff += new WornOffHandler(aug_WornOff);
                    AbilityTarget.BuffList.Add(aug);
                    Console.WriteLine("Your soothing voice has put {0} to sleep...", AbilityTarget.Name);
                }
                else
                {
                    Console.WriteLine("{0} must not be very tired...", AbilityTarget.Name);
                }
            }
            else
            {
                Console.WriteLine("{0} is already active", Name);
            }
        }

        private void aug_WornOff()
        {
            Console.WriteLine("{0} has woke up!", PlayerManager.Player1.Name);
            Console.WriteLine(String.Empty);
        }
    }
}
